﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title>Simple GeoRSS</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

      <script type="text/javascript">
          var map = null;
          var MM = Microsoft.Maps;
          var infobox = null;
          var collectionInfoBox = null;

          function GetMap() {
              var options = { credentials: "YOUR_BING_MAPS_KEY",
                  mapTypeId: Microsoft.Maps.MapTypeId.road,
                  center: new MM.Location(54.87350326912944, 15.333815098500053),
                  zoom: 4
              };
              map = new MM.Map(document.getElementById('divMap'), options);

              // Hide the info box when the map is moved.
              MM.Events.addHandler(map, 'viewchange', hideInfobox);
          }

          function LoadModule() {
              // Register and load a new module
              MM.registerModule("SimpleGeoRSSModule", "scripts/SimpleGeoRSSModule.js");
              MM.loadModule("SimpleGeoRSSModule", { callback: ModuleLoaded });
          }

          function ModuleLoaded() {
              // Use the function provided by the newly loaded module
              var myModule = new GeoRSSModule(map);
              myModule.ImportGeoRSS(document.getElementById("txtGeoRSS").value);
              collectionInfoBox = new MM.EntityCollection;
              map.entities.push(collectionInfoBox);
          }

          //Display InfoBox
          function showInfoBox(e) {
              if (e.targetType == "pushpin") {
                  collectionInfoBox.clear();
                  infobox = new MM.Infobox(e.target.getLocation(), { title: e.target.title, description: e.target.description, offset: new MM.Point(0, 30), visible: true });
                  collectionInfoBox.push(infobox);
              }
              else if (e.targetType == "polygon" || e.targetType == "polyline") {
                  collectionInfoBox.clear();
                  infobox = new MM.Infobox(new MM.Location(e.target.anchorLat, e.target.anchorLon), { title: e.target.title, description: e.target.description, offset: new MM.Point(0, 0), visible: true });
                  collectionInfoBox.push(infobox);
              }
          }

          function hideInfobox(e) {
              try {
                  infobox.setOptions({ visible: false });
              }
              catch (err) {
              }
          }
      </script>
   </head>
   <body onload="GetMap();">
    <div id='divCtrl'>
          <a style="margin-left:10px">GeoRSS-Feed</a>
          <input id="txtGeoRSS" type="text" style="margin-top:4px; margin-left:5px" value="data/MSFT_London.xml" />
          <input id="Button1" type="button" value="Import" onclick="LoadModule()" />
      </div>

      <div id='divMap' style="position:relative;width:600px; height:600px;"></div>
   </body>
</html>